let http = require('http');


let {spawn} = require('child_process')
let server = http.createServer(function(req, res) {

    console.log(req.method, req.url);

    if(req.method == 'POST' && req.url == '/webhook') {

        let buffers = []

        req.on('data', function(buffer) {
            buffers.push(buffer)
        })

        req.end('end', function(buffer) {
            let body = Buffer.concat(buffers)

        })

        res.setHeader('Content-Type', 'application/json')

        res.end(JSON.stringify({ok:true}))


        let child = spawn('sh', [`./${payload.repository.name}.sh`])
    } else {
        res.end('nnnnnnnn')
    }
})


server.listen(8201, () => {
    console.log('在8201 端口监听');
})